package com.ruoyi.ipms_patent.config;

import com.ruoyi.common.core.constant.RabbitMQConstants;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/*RabbitMQ配置*/
@Configuration
public class RabbitMQConfig {

    //队列
    @Bean
    public Queue emailTopicQueue() {
        return new Queue(RabbitMQConstants.EMAIl_QUEUE);
    }

    //交换机
    @Bean
    public TopicExchange emailTopicExchange() {
        return new TopicExchange(RabbitMQConstants.EMAIl_EXCHANGE);
    }

    //绑定主题
    @Bean
    public Binding bindingEmailTopicQueue() {
        return BindingBuilder.bind(emailTopicQueue()).to(emailTopicExchange()).with(RabbitMQConstants.EMAIl_ROUTING_KEY);
    }
}
